import { IObject, udp } from '@cscec/udp-mobile-ui';
import request from 'umi-request';

/**
 * 获取句子详情
 * @param param 参数
 * @returns
 */
export async function registerForParent(param) {
  try {
    const res = await udp.request.body({
      url: '/api/user/registerForParent',
      data: param
    });
    return res
  } catch (e) {
    return "报错信息"
  }
}

// 新增的图片上传方法
export async function uploadImage(file: File, fileType: number = 4) {
  const formData = new FormData();
  formData.append('file', file);
  const authToken = localStorage.getItem('__login__');
    // 构建请求头
  const headers = {};
  // 添加认证令牌
  if (authToken) {
    headers['user-token'] = authToken;
  }
  
  return request(`/api/minio/uploadImage?fileType=${fileType}`, {
    method: 'POST',
    data: formData,
    // 注意：不要设置 Content-Type，让浏览器自动设置 multipart/form-data
    headers: headers,
  });
}
